import { TAllTypes, IValue, IValueNumber, IPosition } from '../../types';
import { AFunc, IPositionValue } from '../types';
import { calculate } from '../../calculate';
import { parseToNumber } from '../../utils';
export class Max extends AFunc {
  public excute(args: TAllTypes[]): TAllTypes[] {
    let max: IValueNumber = {type: 'value', dataType: 'number', value: -Infinity};
    for(let item of args) {
      let valss = this.transformToRangeValue(item);
      for(let vals of valss) {
        for(let val of vals) {
          if(val.type === 'value' && (val.dataType === 'number' || (val.dataType === 'string' && val.value != '' && !isNaN(Number(val.value))))) {
            let num = parseToNumber(val);
            if(num.value > max.value) {
              max = num;
            }
          }
        }
      }
    }
    if(max.value === -Infinity) {
      return [{type: 'value', dataType: 'number', value: 0}]
    }
    return [max];
  }
  
}